package bishi.beike;

import java.util.Arrays;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/13 21:13
 */
public class three {
    public static void main(String[] args) {
        System.out.println(section(new int[]{2, 4, 8}, 6));
    }

    public static long section(int[] a, int t) {
        int max = Arrays.stream(a).max().getAsInt();
        int[] nums = new int[max + 1];
        int len = a.length;
        //找出两点
        //去除包含两点的全部组合
        long res = len * (len - 1) / 2;
        for (int j : a) {
            nums[j]++;
        }
        for (int i = 2; i < max + 1; i++) {
            int now = t ^ i;
            if (now <= max && nums[now] != 0) {
                res -= nums[i] * nums[now];
                nums[i] = 0;
                nums[now] = 0;
            }
        }
        return res;


        // write code here
    }
}
